package com.jtny.nytb.config.measurementunit.service;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.jtny.component.entity.PageData;
import com.jtny.component.exception.ServiceException;
import com.jtny.nytb.config.measurementunit.dto.MeasurementUnitDTO;
import com.jtny.nytb.config.measurementunit.dto.MeasurementUnitPageQueryDTO;
import com.jtny.nytb.config.measurementunit.dto.RepeatMeasurementUnitDTO;
import com.jtny.nytb.config.measurementunit.vo.MeasurementUnitPageQueryParamVO;
import com.jtny.nytb.config.measurementunit.vo.MeasurementUnitVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 计量单位业务接口
 * @package com.jtny.nytb.config.measurementUnit.biz
 * @fileName MeasurementUnitBiz.java
 * @author 智慧能源中心-lyq
 * @createTime 2023年09月01日 10:55
 * @version 1.0
 * @Copyright© 2023 jtny
 * 江投能源技术研究院 版权所有
 */
@Service
public interface MeasurementUnitService {

    /**
     * 新增计量单位操作
     * @param measurementUnitVO 计量单位VO对象
     * @return 计量单位VO对象
     * @throws ServiceException 抛出异常
     */
    MeasurementUnitVO saveMeasurementUnit(MeasurementUnitVO measurementUnitVO) throws ServiceException;

    /**
     * 查询计量单位操作
     * @param measurementUnitId 计量单位ID
     * @return 计量单位VO对象
     * @throws ServiceException 抛出异常
     */
    MeasurementUnitVO detailMeasurementUnit(Long measurementUnitId) throws ServiceException;

    /**
     * 更新计量单位操作
     * @param measurementUnitVO 计量单位VO对象
     * @throws ServiceException 抛出异常
     */
    void updateMeasurementUnit(MeasurementUnitVO measurementUnitVO) throws ServiceException;

    /**
     * 删除计量单位
     * @param measurementUnitId 计量单位Id
     * @throws ServiceException 抛出异常
     */
    void deleteMeasurementUnit(Long measurementUnitId) throws ServiceException;

    /**
     * 禁用计量单位
     * @param measurementUnitId 计量单位Id
     * @throws ServiceException 抛出异常
     */
    void disableMeasurementUnit(Long measurementUnitId) throws ServiceException;

    /**
     * 启用计量单位
     * @param measurementUnitId 计量单位Id
     * @throws ServiceException 抛出异常
     */
    void enableMeasurementUnit(Long measurementUnitId) throws ServiceException;

    /**
     * 批量保存
     *
     * @param measurementUnitDTOList 测量单位 dtolist
     * @return {@link Boolean}
     */
    Boolean saveBatch(List<MeasurementUnitDTO> measurementUnitDTOList);
    /**
     * 保存计量单位信息
     * @param measurementUnitDTO 计量单位信息DTO对象
     * @return 返回保存后的计量单位信息DTO对象
     * @throws ServiceException 抛出异常
     */
    @ApiOperation("保存计量单位信息")
    @ApiImplicitParam(name = "measurementUnitDTO", value = "计量单位信息DTO对象", required = true, paramType = "query")
    @ApiOperationSupport(order = 1)
    @PostMapping("/save")
    @ResponseBody
    MeasurementUnitDTO save(@RequestBody MeasurementUnitDTO measurementUnitDTO) throws ServiceException;

    /**
     * 修改计量单位信息
     * @param measurementUnitDTO 计量单位信息DTO对象
     * @throws ServiceException 抛出异常
     */
    @ApiOperation("修改计量单位信息")
    @ApiImplicitParam(name = "measurementUnitDTO", value = "计量单位信息DTO对象", required = true, paramType = "query")
    @ApiOperationSupport(order = 2)
    @PutMapping("/update")
    @ResponseBody
    void update(@RequestBody MeasurementUnitDTO measurementUnitDTO) throws ServiceException;

    /**
     * 通过主键id获取计量单位信息
     * @param id 主键id
     * @return 返回计量单位信息
     */
    @ApiOperation("通过主键id获取计量单位信息")
    @ApiImplicitParam(name = "id", value = "主键id", required = true, paramType = "path")
    @ApiOperationSupport(order = 3)
    @RequestMapping("/getById/{id}")
    @ResponseBody
    MeasurementUnitDTO getById(@PathVariable("id") Long id);

    PageData<MeasurementUnitVO> queryByPage(MeasurementUnitPageQueryParamVO measurementUnitPageQueryParamVO) throws ServiceException;

    PageData<MeasurementUnitDTO> queryPage(@Valid MeasurementUnitPageQueryDTO measurementUnitPageQueryDTO);

    /**
     * 根据计量单位名称查询计量单位信息
     * @param repeatMeasurementUnitDTO 计量单位查重信息
     * @return 计量单位信息
     */
    @ApiOperation("根据计量单位名称查询计量单位信息")
    @ApiImplicitParam(name = "repeatMeasurementUnitDTO", value = "计量单位查重信息", required = true, paramType = "query")
    @ApiOperationSupport(order = 5)
    @PostMapping("/queryMeasurementUnitByName")
    @ResponseBody
    List<MeasurementUnitDTO> queryMeasurementUnitByName(@RequestBody RepeatMeasurementUnitDTO repeatMeasurementUnitDTO);

    /**
     * 根据计量单位编号查询计量单位信息
     * @param repeatMeasurementUnitDTO 计量单位查重信息
     * @return 计量单位信息
     */
    @ApiOperation("根据计量单位编号查询计量单位信息")
    @ApiImplicitParam(name = "repeatMeasurementTypeDTO", value = "计量单位查重信息", required = true, paramType = "query")
    @ApiOperationSupport(order = 6)
    @PostMapping("/queryMeasurementUnitByCode")
    @ResponseBody
    List<MeasurementUnitDTO> queryMeasurementUnitByCode(@RequestBody RepeatMeasurementUnitDTO repeatMeasurementUnitDTO);

    /**
     * 通过计量单位名称获取计量单位id
     * @param unitName 计量单位名称
     * @return 返回计量单位id
     */
    @ApiOperation("通过计量单位名称获取计量单位id")
    @ApiImplicitParam(name = "UnitName", value = "计量单位名称", required = true, paramType = "path")
    @ApiOperationSupport(order = 7)
    @RequestMapping("/getIdByUnitName/{unitName}")
    @ResponseBody
    List<Long> getIdByUnitName(@PathVariable("unitName") String unitName);

}
